package com.blog.controller;

import com.blog.order.Order;
import com.blog.properties.OrderProperties;
import com.blog.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName OrderController
 * @Destription
 * @Author 天堂小野花
 * @Date 2025/7/31  21:58
 * @Version 1.0
 */
@RestController
public class OrderController {
    @Autowired
    OrderService orderService;
    @Autowired
    OrderProperties orderProperties;
    @GetMapping("/config")
    public String config(){
        return orderProperties.toString();
    }
    @GetMapping("/create")
    public Order createOrder(@RequestParam("productId") Integer productId,
                             @RequestParam("userId") Integer userId){
        Order order = orderService.createOrder(productId, userId);

        return order;
    }

    @GetMapping("/seckill")
    public Order seckillOrder(@RequestParam("productId") Integer productId,
                             @RequestParam("userId") Integer userId){
        Order order = orderService.createOrder(productId, userId);
        order.setNickName("秒杀链路");
        return order;
    }
}
